package com.mallcai.bigdata.ladon.service.peekdata;

import com.mallcai.bigdata.ladon.dpl.entity.peekdata.Peek;
import com.mallcai.bigdata.ladon.dpl.entity.peekdata.PeekRule;
import com.mallcai.bigdata.ladon.dpl.vo.PeekRuleType;
import com.mallcai.bigdata.ladon.vo.DataVo;

import java.util.List;
import java.util.Map;

/**
 * Created by oneape<oneape15@163.com>
 * Created 2019-05-22 16:40.
 * Modify:
 */
public interface IPeekService {

    int addPeek(Peek peek, List<PeekRule> rules);

    int editPeek(Peek peek, List<PeekRule> rules);

    int deletePeek(Peek peek);

    Peek getById(Long peekId);

    List<Peek> getByParams(Map<String, Object> params);

    /**
     * 根据取数id获取规则
     *
     * @param peekId Long
     * @return List
     */
    List<PeekRule> getRuleByPeekId(Long peekId);

    /**
     * 计算数据条数
     *
     * @param modelId Long 模型Id
     * @param rules   List 规则列表
     * @return Long 数据条数
     */
    Long countDataSize(Long modelId, List<PeekRule> rules);

    /**
     * 预览数据
     *
     * @param modelId Long 模型Id
     * @param fields  返回字段集
     * @param rules   List 规则列表
     * @return DataVo
     */
    DataVo previewData(Long modelId, String fields, List<PeekRule> rules);

    /**
     * 发送数据到当前用户邮箱
     *
     * @param peekId Long
     * @return int 1 - 成功; 0 - 失败
     */
    int sendData2Me(Long peekId);

    /**
     * 获取所有数据类型的规则
     *
     * @return Map
     */
    Map<String, List<Map<String, String>>> getAllDataRule();

    /**
     * 添加取数
     * @param peek
     * @return
     */
    int saveQuery(Peek peek);

    /**
     * 增加取数次数
     * @param peekId
     * @return
     */
    int incPeekNum(Long peekId);
}
